<template>
  <search title="请输入仪器名称"/>
  <view v-for="k in data" :key="k">
    <view class="photo-box">
      <image src="@/static/images/打印机.jpg" class="photo-left"/>
      <view class="photo-right" @click="reserve">
        <notice
            :title="k.title"
            :time="k.time"
            :people="k.people"
            :content="k.content"
        />
        <view v-if="k.subscribed">
          <image src="@/static/images/预约.png" class="subscribed"/>
          <view class="subscribed-time">{{ k.subscribed }}</view>
        </view>
        <view v-else>
          <image src="@/static/images/未预约.png" class="subscribed"/>
        </view>
      </view>
    </view>
  </view>
  <Under :selected="1"/>
</template>

<script setup lang="ts">
import Under from "@/components/tail/under.vue";
import Search from "@/components/head/search.vue";
import Notice from "@/components/card/notice.vue";
import {onMounted, reactive} from "vue";
import axios from "axios";

const data = reactive([])

onMounted(() => {
  axios.get("http://localhost:24154/api/list/index").then((resp) => {
    console.log(resp.data)
    if (resp.status == 200) {
      data.push(resp.data)
    }
  })
})

function reserve() {
  uni.switchTab({url: "/pages/subscribe/index"})
}
</script>
